package Run_System;

import java.util.Scanner;

public  class Exercises_Generation_System {
    private static Exercises exercises = null;
    public  static void printTitle(){                    //生成标题栏
        System.out.println("-----------------------------------------------------------");
        System.out.println("-        口算练习习题    -");
        System.out.println("-  每次运行程序可得到一套习题及答案  -");
        System.out.println("-----------------------------------------------------------");
        System.out.println();
    }
    public  static void generateExercises(){      //生成习题册
        int max = 100;
        int min = 0;
        System.out.println("请输入操作数范围 max:  min:");
        Scanner in = new Scanner(System.in);
        max = in.nextInt();
        min = in.nextInt();
        while(true) {
            System.out.println("请选择生成习题的类型： 1：加法模式  2：减法模式  3：加减交替模式");
            int pattern = in.nextInt();
            System.out.println("请输入习题数量");
            int amount = in.nextInt();
            switch (pattern) {
                case 1:
                case 2:
                    exercises = ExervisesFactory.generateExercises(pattern,amount);
                    return;
                case 3:
                    exercises = ExervisesFactory.generateExercises(pattern,amount,50);
                    return;
                default:
                    System.out.println("请输入数字类型");
            }
        }
    }
    public static void printExercises(){       //输出习题
        ExercisesSheet.printExercises(exercises.iterator());
    }
    public static void printCalculations() {         //输出习题答案
        System.out.println("-----------------------------------------------------------");
        System.out.println("-  下面是习题的参考答案");
        System.out.println("-----------------------------------------------------------");
        ExercisesSheet.printCaculations(exercises.iterator());
    }

    public static void main(String[] args) {
        printTitle();
        generateExercises();
        printExercises();
        printCalculations();
    }
}
